import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_learn_vi/src/bean/bean_eails.dart';
import 'package:flutter_learn_vi/src/net/dio_utils.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2021/1/13.
///
/// 可关注公众号：我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂：https://study.163.com/instructor/1021406098.htm
/// 可关注博客：https://blog.csdn.net/zl18603543572
///
/// 代码清单
///
class EamilsDetailsPage extends StatefulWidget {
  final EailsBean eailsBean;

  EamilsDetailsPage(this.eailsBean);

  @override
  _EamilsDetailsPageState createState() => _EamilsDetailsPageState();
}

class _EamilsDetailsPageState extends State<EamilsDetailsPage> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    widget.eailsBean.isRead = "Y";
    commitNetDataFunction();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("信箱详情"),
      ),
      backgroundColor: Colors.white,

      ///填充布局
      body: Container(
        padding: EdgeInsets.all(10),
        child: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisSize: MainAxisSize.min,
            children: [
              Row(
                children: [
                  Text(
                    "${widget.eailsBean.userEntity.reamName}",
                    style: TextStyle(
                        fontSize: 16,
                        color: Colors.black,
                        fontWeight: FontWeight.w500),
                  ),
                  SizedBox(
                    width: 10,
                  ),
                  Expanded(
                    child: Text(
                      "(${widget.eailsBean.userEntity.username})",
                      style: TextStyle(
                          fontSize: 14,
                          color: Colors.black87,
                          fontWeight: FontWeight.normal),
                    ),
                  ),
                ],
              ),
              SizedBox(
                height: 8,
              ),
              Text(
                "${widget.eailsBean.content}",
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                    fontSize: 14,
                    color: Colors.grey[600],
                    fontWeight: FontWeight.normal),
              ),
              SizedBox(
                height: 8,
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: [
                  Text(
                    "${widget.eailsBean.createTime}",
                    style: TextStyle(
                        fontSize: 14,
                        color: Colors.grey[600],
                        fontWeight: FontWeight.normal),
                  ),
                ],
              )
            ],
          ),
        ),
      ),
    );
  }

  void commitNetDataFunction() async {
    String url = HttpHelper.barmasterletterDelRead + "/${widget.eailsBean.id}";
    ResponseInfo partResponseInfo = await DioUtils.instance.putRequest(
      url: url,
    );
  }
}
